#!/usr/bin/env python3
"""
Agent客户端配置
"""

import os
from pathlib import Path


class ClientConfig:
    """客户端配置类"""
    
    def __init__(self):
        # MCP服务器配置
        self.mcp_server_url = os.getenv("MCP_SERVER_URL", "http://localhost:8000")
        self.mcp_generator_url = os.getenv("MCP_GENERATOR_URL", "http://localhost:8010")
        self.mcp_manager_url = os.getenv("MCP_MANAGER_URL", "http://localhost:8011")
        
        # RAG配置
        self.max_search_results = int(os.getenv("MAX_SEARCH_RESULTS", "5"))
        self.knowledge_base_refresh_interval = int(os.getenv("KB_REFRESH_INTERVAL", "300"))  # 5分钟
        
        # RAG高级配置（用于覆盖全局配置）
        self.rag_final_top_k = int(os.getenv("AGENT_RAG_FINAL_TOP_K", "3"))  # Agent默认返回3个函数
        self.rag_candidate_k = int(os.getenv("AGENT_RAG_CANDIDATE_K", "50"))  # 候选函数数量
        self.rag_rerank_top_k = int(os.getenv("AGENT_RAG_RERANK_TOP_K", "15"))  # Rerank返回数量
        self.enable_rag_rerank = os.getenv("AGENT_ENABLE_RAG_RERANK", "true").lower() == "true"
        
        # 会话配置
        self.max_session_messages = int(os.getenv("MAX_SESSION_MESSAGES", "50"))
        self.session_timeout_minutes = int(os.getenv("SESSION_TIMEOUT_MINUTES", "30"))
        
        # 日志配置
        self.log_level = os.getenv("LOG_LEVEL", "INFO")
        self.log_file_max_size = int(os.getenv("LOG_FILE_MAX_SIZE", "10485760"))  # 10MB
        
        # 客户端配置
        self.client_name = os.getenv("CLIENT_NAME", "MCP-Agent-Client")
        self.client_version = "2.0.0"
        
        # 功能开关
        self.enable_function_validation = os.getenv("ENABLE_FUNCTION_VALIDATION", "true").lower() == "true"
        self.enable_auto_kb_refresh = os.getenv("ENABLE_AUTO_KB_REFRESH", "true").lower() == "true"
        self.enable_chat_sessions = os.getenv("ENABLE_CHAT_SESSIONS", "true").lower() == "true"


# 全局配置实例
client_config = ClientConfig()